package thread.test_3.demo_1;

public class Foodie extends Thread{
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.LOCK) {
                if (Desk.food == 0) {
                    break;
                } else {
                    if (Desk.flag) {
                        System.out.println("用力的吃了一个汉堡");
                        Desk.flag = false;
                        Desk.food--;
                        Desk.LOCK.notify();
                    } else {
                        try {
                            Desk.LOCK.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
